package model

type BaseResult struct {
	Count int
	Code  string
	Msg   string
	Data  interface{}
}

// 构建基础对象
func Build(code string, msg string, data interface{}) (result BaseResult) {
	result.Code = code
	result.Msg = msg
	result.Data = data
	return result
}

func BuildFail(msg string) (result BaseResult) {
	result.Code = "A001"
	result.Msg = msg
	return result
}

func BuildFailWithNoParam() (result BaseResult) {
	return BuildFail("默认错误")
}

func BuildSuccess(msg string, data interface{}) (result BaseResult) {
	return Build("200", msg, data)
}

//
func BuildSuccessWithNoParam() (result BaseResult) {
	return Build("200", "success", nil)
}

func BuildSuccessWithData(data interface{}) (result BaseResult) {
	return Build("200", "success", data)
}
